$(function () {

    $('#table').bootstrapTable({
        url: '${pageContext.request.contextPath}/../../house/list2',
        columns: [
            {
                field: 'id',
                title: 'id',
                visible : false,
            },{
                field: 'doornumber',
                title: '房屋门牌号'
            },{
                field: 'userdetails.name',
                title: '姓名',
            },
            {
                field: 'userdetails.phone',
                title: '手机号',
            },{
                field: 'userdetails.sfz',
                title: '身份证号码',
            },{
                field: 'userdetails.property.name',
                title: '产权',
            },{
                field: 'sale.name',
                title: '楼'
            },{
                field: 'danyuan.name',
                title: '单元'
            },{
                field: 'floor',
                title: '层数'
            },{
                field: 'huxing.name',
                title: '户型'
            },{
                field: 'direction.name',
                title: '房屋朝向'
            },{
                field: 'measure',
                title: '平米',
                formatter: function (value, row, index) {
                    var jia = row .measure+"平方米";
                    return jia;
                }
            },{
                field:'remark',
                title:'简介'
            }],
        contentType:"application/x-www-form-urlencoded",
        queryParamsType: '',
        //修改分页的默认对数
        //offset,limit
        height: 700,
        pageNumber: 1,
        pageSize: 15,
        pagination:true,
        queryParams: queryParams,
        sidePagination:'server',
    });


})

function search() {
    var opt = $("#table").bootstrapTable('getOptions');

    var shu ;
    var node = $('#tt').tree('getSelected');
    if (node){
        var s = node.text;
        if (node.attributes){
            s += ","+node.attributes.p1+","+node.attributes.p2;
        }
        shu = s;
    }

    var men = $("#men").val();
    var zhuangtai=$("#zhuangtai").val();

    $.post('${pageContext.request.contextPath}/../../house/list2', {
        'shu':shu,
        'type': 2,
        'number':men,
        'pageSize': opt.pageSize,
        'name':zhuangtai,
        'pageNumber': 1
    }, function (data) {

        //重新给table绑定数据
        $("#table").bootstrapTable("load", data);
    });
}


function queryParams(params) {
    var shu ;
    var node = $('#tt').tree('getSelected');
    if (node){
        var s = node.text;
        if (node.attributes){
            s += ","+node.attributes.p1+","+node.attributes.p2;
        }
        shu = s;
    }
    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        'pageSize': params.pageSize,  //页面大小
        'pageNumber': params.pageNumber, //页码
        'shu':shu,
        'type' :2,
        'name':$("#zhuangtai").val(),
        'number':$("#men").val(),
    };
    return temp;
};